package com.avic.rong.goodsSort.api.secondListApi;

import com.avic.rong.api.HttpPostService;
import com.example.minato.minastore.BaseApi;
import com.example.minato.minastore.listener.HttpOnNextListener;
import com.trello.rxlifecycle2.components.support.RxAppCompatActivity;

import io.reactivex.Observable;
import retrofit2.Retrofit;

/**
 * Created by Chenjiaxin on 2019/7/24 14:10
 * E-Mail Address：16601203965@163.com
 */
public class GoodsSortSearchAllBzApi extends BaseApi {

    private String state;
    private int types;
    private String keyword;
    //    private String catIds;
//    private String attrPro ;
//    private String typeId ;
    private int sort;
//    private String postTime ;
    private int pageNo ;
    private int pageSize ;


    public GoodsSortSearchAllBzApi(RxAppCompatActivity rxAppCompatActivity, HttpOnNextListener listener, String state, int types, String keyword, int pageNo, int pageSize) {
        super(rxAppCompatActivity, listener);
        setCache(false);
        this.state = state;
        this.types = types;
        this.keyword = keyword;
        this.pageNo = pageNo;
        this.pageSize = pageSize;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public void setSort(int sort) {
        this.sort = sort;
    }

    public GoodsSortSearchAllBzApi(RxAppCompatActivity rxAppCompatActivity, HttpOnNextListener listener, String state, int types, String keyword, int sort) {
        super(rxAppCompatActivity, listener);
        this.state = state;
        this.types = types;
        this.keyword = keyword;
        this.sort = sort;
    }

    @Override
    public Observable getObservable(Retrofit retrofit) {
        HttpPostService service = retrofit.create(HttpPostService.class);
        if (state.equals("1")){
            return service.searchAllBz(types,keyword,pageNo,pageSize);
        }else {
            return service.searchAllBzTime(types,sort,keyword);
        }
    }

}
